﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using STLGROUP.Layers.DataAccessLayers;

namespace QuanLyBanHang
{
    /// <summary>
    /// Giam So Luong San Pham Dang Chon
    /// <author>Van Long</author>
    /// <date>14/05/2012</date>
    /// </summary>
    public partial class MF006E : Form
    {

        #region Member variables

        private DT_SanPham _product;
        private int _soLuongDangChon;
        private static int _soLuongGiam; 

        #endregion

        #region Constructors

        public MF006E(DT_SanPham product, int soLuongDangChon)
        {
            InitializeComponent();

            _product = product;
            _soLuongDangChon = soLuongDangChon;
        } 

        #endregion

        #region Public Methods

        public static int GetSoLuongGiam()
        {
            return _soLuongGiam;
        } 

        #endregion

        #region Events

        private void MF006E_Load(object sender, EventArgs e)
        {
            txtMaSanPham.Text = _product.MaSanPham;
            txtSLToiDa.Text = _soLuongDangChon.ToString();
            iipSL.MinValue = 1;
            iipSL.Value = iipSL.MinValue;
            iipSL.MaxValue = _soLuongDangChon;
        }

        private void chkTatCa_CheckedChanged(object sender, EventArgs e)
        {
            if (chkTatCa.Checked)
            {
                iipSL.Value = iipSL.MaxValue;
            }
            else
            {
                iipSL.Value = iipSL.MinValue;
            }
        }

        private void btnDongY_Click(object sender, EventArgs e)
        {
            _soLuongGiam = iipSL.Value;
            this.Close();
        }

        private void btnHuyChon_Click(object sender, EventArgs e)
        {
            _soLuongGiam = 0;
            this.Close();
        } 

        #endregion

    }
}
